const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
const path = require('path');
const cesiumSource = './node_modules/cesium/Source'
const cesiumWorkers = '../Build/Cesium/Workers'
const cesiumFile = 'cesium3D'
const buildName = 'battlefield-situation' // 这个就是路由地址前缀
module.exports = {
  lintOnSave:false,
  publicPath:'./',
  outputDir: buildName,
  assetsDir: 'static',
  configureWebpack: {
    resolve: {
      alias: {
        'cesium': path.resolve(__dirname, cesiumSource)
      }

    },
    // 解决静态资源引入路径问题
    plugins: [
      new CopyWebpackPlugin({
        patterns: [
          { from: path.join(cesiumSource,cesiumWorkers), to: path.join(cesiumFile,'Workers') },
          { from: path.join(cesiumSource,'Workers'), to: path.join(cesiumFile,'Workers') },
          { from: path.join(cesiumSource,'Assets'), to: path.join(cesiumFile,'Assets' )},
          { from: path.join(cesiumSource,'Widgets'), to: path.join(cesiumFile,'Widgets') },
          { from: path.join(cesiumSource,'ThirdParty/Workers'), to: path.join(cesiumFile,'WoThirdParty/Workersrkers') },
        ]
      }),
      // 解决无法确定base路径问题
      new webpack.DefinePlugin({
        CESIUM_BASE_URL: JSON.stringify(path.join('./',cesiumFile))
      })
    ],
    //解决打包导出文件错误
    module: {
      unknownContextCritical: false
    }
  },
  devServer: {
    // 关闭浏览器页面的报错遮罩层
    client: {
      overlay: false
    },
    // 配置 end
  }
}
